package com.uxwine.alarm.db;

import android.net.Uri;
import android.provider.BaseColumns;

public interface TBAlram
{
	static final String TAG					= "alarm";
	static final String TB_NAME 			= "tb_" + TAG;
	static final String MATCH_DIR 			= TAG;
	static final String MATCH_ITEMS			= TAG + "/#";
	static final String VDN_DIR				= "vnd.android.cursor.dir/" + TAG;
	static final String VDN_ITEMS			= "vnd.android.cursor.item/" + TAG;

	/**
     * The content:// 为这个表定义一个共享的Url
     */
    public static final Uri CONTENT_URI = Uri.parse(AlarmProvider.buildContentUri(TAG));
    
    /**
     * The default sort order for this table
     */
    public static final String DEFAULT_SORT_ORDER = Columns.TRIGGER + ", " + Columns.TIME + " ASC";

    // Used when filtering enabled alarms.
    public static final String WHERE_ENABLED = Columns.ENABLED + "=1";
    
    /**
     * the string of create table for database
     * 
     * _id<br/>
     * enable<br/>
     * time<br/>
     * cycle<br/>
     * trigger<br/>
     * vibrate<br/>
     * label<br/>
     * alert<br/>
     */
    public static final String TABLE_DEFINE = 
    "(" + 
    	Columns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 	//id
    	Columns.ENABLED + " INTEGER, " + 						//enable
    	Columns.TIME + " TEXT, " +								//time
    	Columns.CYCLE + " INTEGER, " +							//cycle
    	Columns.CYCLE_FLAGS + " INTEGER, " +					//cycle flags
    	Columns.TRIGGER + " INTEGER, " +						//trigger
    	Columns.VIBRATE + " INTEGER, " + 						//vibrate
    	Columns.LABEL + " INTEGER, " + 							//label
    	Columns.ALERT + " INTEGER" +							//alert
   	")";
    
    /**
     * the string of insert table for database
     * 
     * enable<br/>
     * time<br/>
     * cycle<br/>
     * cycle flags<br/>
     * trigger<br/>
     * vibrate<br/>
     * label<br/>
     * alert<br/>
     */
    public static final String TABLE_INSERT_ALL = 
    "(" + 
    	Columns.ENABLED + ", " + 						//enable
    	Columns.TIME + ", " +							//time
    	Columns.CYCLE + ", " +							//cycle
    	Columns.CYCLE_FLAGS + ", " +					//cycle flags
    	Columns.TRIGGER + ", " +						//trigger
    	Columns.VIBRATE + ", " + 						//vibrate
    	Columns.LABEL + ", " + 							//label
    	Columns.ALERT +									//alert
   	")";
    
    /**
     * the string of insert table for database
     * 
     * enable<br/>
     * time<br/>
     * cycle<br/>
     * flags<br/>
     * trigger<br/>
     * vibrate<br/>
     * label<br/>
     * alert<br/>
     */    
    static final String[] QUERY_COLUMNS = 
    {
    	Columns._ID, 
    	Columns.ENABLED, 
    	Columns.TIME, 
    	Columns.CYCLE, 
    	Columns.CYCLE_FLAGS, 
    	Columns.TRIGGER, 
    	Columns.VIBRATE, 
    	Columns.LABEL, 
    	Columns.ALERT 
    };
    
	/**
	 * @author 	zhangzhongming<QQ:911696301>
	 * @date	2013.4.28
	 * @brief   Alarm的列名，Provider数据库相关
	 *
	 * */
	public static interface Columns extends BaseColumns
	{

        /**
         * Hour in 24-hour localtime 0 - 23.
         * <P>Type: INTEGER</P>
         */
        public static final String TIME = "timebase";
        
        /**
         * Days of week coded as integer
         * <P>Type: INTEGER</P>
         */
        public static final String CYCLE = "timecycle";
        
        /**
         * Days of week coded as integer
         * <P>Type: INTEGER</P>
         */
        public static final String CYCLE_FLAGS = "timeflags";

        /**
         * Alarm time in UTC milliseconds from the epoch.
         * <P>Type: INTEGER</P>
         */
        public static final String TRIGGER = "timetrigger";

        /**
         * True if alarm is active
         * <P>Type: BOOLEAN</P>
         */
        public static final String ENABLED = "enabled";

        /**
         * True if alarm should vibrate
         * <P>Type: BOOLEAN</P>
         */
        public static final String VIBRATE = "vibrate";

        /**
         * Message to show when alarm triggers
         * Note: not currently used
         * <P>Type: STRING</P>
         */
        public static final String LABEL = "_label";

        /**
         * Audio alert to play when alarm triggers
         * <P>Type: STRING</P>
         */
        public static final String ALERT = "alert";        

        /**
         * These save calls to cursor.getColumnIndexOrThrow()
         * THEY MUST BE KEPT IN SYNC WITH QUERY_COLUMNS
         * @see TBAlram.QUERY_COLUMNS
         */
        public static final int INDEX_ID 			= 0;
        public static final int INDEX_ENABLE		= 1;
        public static final int INDEX_TIME 			= 2;
        public static final int INDEX_CYCLE 		= 3;
        public static final int INDEX_CYCLE_FLAGS 	= 4;
        public static final int INDEX_TRIGGER 		= 5;
        public static final int INDEX_VIBRATE 		= 6;
        public static final int INDEX_LABEL 		= 7;
        public static final int INDEX_ALERT 		= 8;
	} 
}
